#pragma once
#include <windows.h>
#include "CSingleton.h"

const float DEFAULT_FPS=25;
namespace Framework
{
	class CFpsController: public CSingleton<CFpsController>
	{
		friend class CSingleton<CFpsController>;
	public:
		void SetLimitFPS(float limitFPS);
		void BeginCounter();
		void EndCounter();
		float GetFrameDt(){return m_iFrameDt;} 
		float GetRuntimeFPS(){return m_iFrameDt?(1000.0f/m_iFrameDt):0;}
		float delta_Time;
		virtual ~CFpsController(){}
	private:
		CFpsController():m_iFrameDt(0),m_iLimitFPS(0),m_iLimmitFrameDt(0)
		{
			if (QueryPerformanceFrequency(&m_Frequency))
			{
				m_IsPerfHardware=true;
				m_StartCount.QuadPart=0;
				QueryPerformanceFrequency(&m_Frequency);
			} 
			else
			{
				m_IsPerfHardware=false;
				m_StartTime=0;
			}
			SetLimitFPS(DEFAULT_FPS);
		}
		bool            m_IsPerfHardware;  

		float m_iLimitFPS;
		float m_iLimmitFrameDt;
		float m_iFrameDt;
		LARGE_INTEGER m_StartCount;
		LARGE_INTEGER m_Frequency;
		DWORD m_StartTime;

	};
}
